﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NewsInformationType.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The news information type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The news information type.
    /// </summary>
    [DataContract]
    public class NewsInformationType
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="newsInformationType">
        /// The news information type.
        /// </param>
        /// <returns>
        /// The <see cref="NewsInformationType"/>.
        /// </returns>
        public static NewsInformationType Convert(Models.Domain.NewsInformationType newsInformationType)
        {
            if (newsInformationType != null)
            {
                var dto = new NewsInformationType { ID = newsInformationType.ID, Name = newsInformationType.Name };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The news information type query.
    /// </summary>
    [DataContract]
    public class NewsInformationTypeQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new NewsInformationTypeActioner(hsession, null);

            return actioner.ExecuteSearchQuery(this);
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The news information type result.
    /// </summary>
    [DataContract]
    public class NewsInformationTypeResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NewsInformationTypeResult"/> class.
        /// </summary>
        public NewsInformationTypeResult()
        {
            this.List = new List<NewsInformationType>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<NewsInformationType> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}

namespace ServiceLibrary.Services.Commands
{
    using System;
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Dto;

    using User = ServiceLibrary.Models.Domain.User;

    /// <summary>
    /// The create news information type command.
    /// </summary>
    [DataContract]
    public class CreateNewsInformationTypeCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the dto.
        /// </summary>
        [DataMember]
        public NewsInformationType Dto { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new NewsInformationTypeActioner(hsession, activeUser);
            actioner.CreateNewsInformationType(this);
        }

        #endregion
    }

    /// <summary>
    /// The update news information type command.
    /// </summary>
    [DataContract]
    public class UpdateNewsInformationTypeCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the dto.
        /// </summary>
        [DataMember]
        public NewsInformationType Dto { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new NewsInformationTypeActioner(hsession, activeUser);
            actioner.UpdateNewsInformationType(this);
        }

        #endregion
    }

    /// <summary>
    /// The delete news information type command.
    /// </summary>
    [DataContract]
    public class DeleteNewsInformationTypeCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the dto.
        /// </summary>
        [DataMember]
        public Guid? Dto { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new NewsInformationTypeActioner(hsession, activeUser);
            actioner.DeleteNewsInformationType(this);
        }

        #endregion
    }
}